<%@ page import="java.util.List" %>
<%@ page import="code.entity.Location" %>
<%@ page import="code.service.LocationService" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    try {
        int currPage = Integer.parseInt(request.getParameter("page"));
        List<Location> list = new ArrayList<Location>();
        int totalPage = 0, pageSize = 10;
        String date = request.getParameter("date") == null ? "" : request.getParameter("date");
        String username = request.getParameter("username") == null ? "" : request.getParameter("username");
        if (date != null && date.length() > 0) {
            list = LocationService.getLocationList(date, username);
        }
        int count = list.size();
        totalPage = count % pageSize == 0 ? count / pageSize : (count / pageSize) + 1;
        for (int i = (currPage - 1) * pageSize; i < currPage * pageSize; i++) {
            if (i == list.size()) break;
            Location l = list.get(i);

%>
<p><a href="javascript:void(0);" onclick="addMarker('<%=l.getX()%>','<%=l.getY()%>');"><%=l.getCreateTime()%>
</a></p>
<%
    }
%>


<a href="javascript:void(0);" onclick="prev(this);" page="<%=currPage%>" totalPage="<%=totalPage%>" url="markers.jsp"
   list="markers" data="&date=<%=date%>&username=<%=username%>">上一页</a>
<%=currPage%>/<%=totalPage%>
<a href="javascript:void(0);" onclick="next(this);" page="<%=currPage%>" totalPage="<%=totalPage%>" url="markers.jsp"
   list="markers" data="&date=<%=date%>&username=<%=username%>">下一页</a>

<%
    } catch (Exception e) {
        e.printStackTrace();
    }
%>
